home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / exelink2.zip / EXELINK.DOC < prev    next >
Text File  |  1993-06-17  |  12KB  |  268 lines

  1.                                   EXELINK.COM
  2.                                   ===========
  3.  
  4. IMPORTANT NOTE:  Needs DOS 3.0 or greater
  5.  
  6. #include <std_disclaimer.h>
  7. All the code in this package is my own work.  No responsibility will be
  8. taken for loss of data or damage caused by running this program.  This
  9. program has been tested and I use it myself, so if you do come across
  10. any problems then let me know!
  11.  
  12. The program can be freely distributed.  There are no restrictions on use.
  13. Just keep my name on it please!
  14. The program is "postcardware" - send me a postcard if you like :-)
  15.  
  16. Introduction
  17. ============
  18. A big problem with Hard discs is that they can store so much data!
  19. This isn't as silly as it sounds; if you have four or five applications
  20. on your disc (maybe Pascal, C, Assembler, Word Processor, Norton etc)
  21. and wish to keep some sort of organisation do your disc then your PATH
  22. variable gets a little large.  Until you reach the dreaded 127
  23. character limit.  Although programs exist that enable you to get up to
  24. 255 characters in the PATH, this is a bit long and unwieldy, and can
  25. make you computer spend too much time skipping around directories just
  26. to find the program you want.  I had this problem and decided to find a
  27. better solution, and EXELINK is it (well I think its better!)
  28.  
  29. What EXELINK does
  30. =================
  31. NOTE: EXELINK will not work with .BAT files since the command shell
  32. interprets them internally and doesn't call the DOS 'exec' routines.
  33. Only routines that call 'exec' (eg .EXE and .COM files, Overlays?)
  34. work.
  35.  
  36. When you execute a command, MS-DOS needs to find where the file is that
  37. you are trying to run.  It first looks in the current directory, then
  38. in the first directory on the PATH, then the next, then the next...
  39. until it finds what you wanted.
  40.  
  41. eg if you have your path set up as
  42. c:\dos;c:\app\turbop;c:\app\turboc;c:\app\tasm;c:\app\wp;c:\app\norton
  43. then typing the command 'nu'  (for norton utilities) will involve
  44. looking for
  45.      .\NU.???
  46.      c:\dos\NU.???
  47.      c:\app\turbop\NU.???
  48.      c:\app\turboc\NU.???
  49.      c:\app\tasm\NU.???
  50.      c:\app\wp\NU.???
  51.      c:\app\norton\NU.???
  52. which it will eventually find.  Any files in any of these directories
  53. which are not executable will slow down the searching...
  54. Of course an easy way to speed up access to NU would be to put it at
  55. the front of the PATH, at the expense of some other program!
  56.  
  57. EXELINK sets aside directory which you include on your PATH (for speed
  58. you put it at the beginning) and this contains a set of files which
  59. appear to DOS to be executable.  Instead of being run though, EXELINK
  60. reads the contents of this file and gets the filename of the REAL
  61. program from there.  Since the link directory is at the beginning of
  62. the PATH and there are only executables it will find the link file very
  63. quickly.
  64. In the example above, you could now have the following setup:
  65. PATH=c:\links;c:\dos
  66. and searching would be
  67.      .\NU.???
  68.      c:\links\NU.???  <- found!  Open the file, read its contents and
  69.                          execute!
  70.  
  71. Less searching is done, executables are found quicker, PATH is shorter
  72. and less disk head movement is used.
  73.  
  74. But what is this I hear?  You can do this by creating a BATch files which
  75. calls the real program?  Almost true, but there are a  few problems with
  76. batch files:
  77.  (1) There is difficulty passing an unknown number of parameters.  A batch
  78.      file such as
  79.      @c:\app\wp %1 %2 %3 %4 %5
  80.      can be taken as meaning that is passes exactly five parameters, some
  81.      of which are NULL (GEM programs can suffer from this problem)
  82.  (2) It only works from the DOS prompt - a program such as MAKE is
  83.      unable to use BATch files unless you specifically call COMMAND.COM
  84.      which is slower and takes more memory.
  85.  (3) It is an interpreted file.  DOS opens the BATch file, reads
  86.      a line.  If it executes an external program, closes the BATch
  87.      file, executes the command, opens the BATch file, etc.  Lots of
  88.      disc accessing...
  89.  
  90. The only real alternative would be to write a specialised Pascal or C
  91. program which just executed the real version with all the parameters
  92. passed on.  This will work in all cases, but has the problem that you
  93. need to compile a new link program for each new executable you want
  94. linked, and even the simplest compiled program takes about 2.5k -
  95. wasting 4k of disc space!
  96. example in Turbo C 2.01:
  97.  
  98. main(int argc,char *argv[], char **envp)
  99. {
  100.   argv[0]="real_name.exe";
  101.   execve("real_path_name.exe",argv,envp);
  102. }
  103.  
  104. Which would then need compiling, and even in the TINY memory model
  105. takes over 3k!
  106.  
  107. Using EXELINK you need to create a 1 line ASCII file which you can do
  108. with the COPY command.
  109. How EXELINK works
  110. =================
  111. EXELINK is a Terminate and Stay Resident (TSR) program.  While resident
  112. it takes an astounding 400 bytes of memory!  The only vector it
  113. attaches to is INT 21h and any call that is not Function 4Bh (exec) is
  114. passed directly onto the original handler.  To cut down on resident size
  115. it frees the environment block passes to it by DOS, and relocates itself
  116. over the PSP, which is no longer needed once the program has gone resident.
  117.  
  118. If the call is an 'exec' then the pathname of the program to be called
  119. is worked out.  If this program is in the EXELINK directory (by default
  120. C:\LINKS) then the file is opened for reading and the contents of the
  121. file (up to 127 characters) are read in.  A little processing is done
  122. to convert this to an ASCIIZ string and then the original routine
  123. continues with this new name.  All registers are preserved through this
  124. except for DS:DX which point to the filenames so any options passed to
  125. 'exec' are preserved.  Also, as far as the called application is concerned,
  126. it was run by typing the full pathname of the program, so that programs that
  127. use the command line (eg WordPerfect) to find the directory it is running
  128. in work properly.
  129.  
  130.  
  131. Requirements
  132. ============
  133. EXELINK makes use of an internal DOS function:  INT 21h Function 60h -
  134. CANONICALIZE FILENAME OR PATH
  135. This is only available on MS-DOS 3.0 onwards, and I am not sure if this is
  136. a fully documented call.
  137.  
  138. EXELINK has been tested with:
  139.      PC-DOS 3.20
  140.      vanilla MS-DOS 3.30
  141.      Atari PC2 specific MS-DOS 3.21
  142.      Tri-Gem MS-DOS 3.30
  143.      OEM MS-DOS 5.0
  144.      4DOS v3.01, v3.02, v3.02a, v4.0, v4.01 (a good COMMAND.COM replacement)
  145.      Windows 3.0, 3.1
  146.      DesqView 386 v2.3, v2.4
  147.      Various applications.
  148.  
  149. Known incompatibilities:
  150.      MKS Tools 3.1c version of the Korn-Shell.
  151.        I have had a lot of problems with the Korn Shell, from TSR's to
  152.        bog-standard applications.  I am unsure as to why this shell fails
  153.        to work with EXELINK since it seems to support INT21/AX=60h
  154.        I have not tested with later versions of MKS tools.
  155.  
  156.      Turbo C exec() call.
  157.        Turbo C seems to try to open the executable and read the header
  158.        contents to determine the file type.  Of course, these files are
  159.        ASCII and so TurboC returns "Invalid exec type" :-(
  160.        This also affects Borland C++ 3.1 (the Run Time Library Sources
  161.        show why Borland do this - to enable exec() to overlay better)
  162.  
  163.      Windows 3.0, 3.1.
  164.        I think Windows also tries to open the file to determine
  165.        if a file is a DOS or a Windows executable.  I am not sure.
  166.        However,  EXELINK works happily inside a DOS window.
  167.      DesqView 386.
  168.        It appears that DesqView has its own exec() replacement, and so
  169.        each window that you wish to use EXELINK in must have its own
  170.        copy of EXELINK loaded.  Once this has happened, it works happily
  171.        inside that window.
  172.      Word Perfect for Windows 5.1
  173.        Word Perfect seems to search the PATH to find where your windows
  174.        system resides, so it knows where to put the INI GRP DLL files.
  175.        If WIN.COM is in the links directory then WP4W assumes this is where
  176.        windows lives!  Silly Word Perfect.....before installing this program
  177.        you should modify your PATH so that it has the real windows directory
  178.        at t